package com.IC.base.service.impl;

import com.IC.base.mapper.ActualEquipmentMapper;
import com.IC.base.service.ActualEquipmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.IC.domain.dto.ActualEquipmentDTO;
import com.IC.domain.po.ActualEquipmentPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActualEquipmentServiceImpl extends ServiceImpl<ActualEquipmentMapper, ActualEquipmentPO> implements ActualEquipmentService {

    @Autowired
    private ActualEquipmentMapper actualEquipmentMapper;

    /**
     * 查询实有设备信息
     * @param actualEquipmentDTO
     * @return
     */
    @Override
    public PageInfo<ActualEquipmentPO> findList(ActualEquipmentDTO actualEquipmentDTO) {
        // 使用PageHelper插件开始分页，设置当前页码和每页显示数量
        PageHelper.startPage(actualEquipmentDTO.getPageNum(), actualEquipmentDTO.getPageSize());
        // 调用实际设备的Mapper接口，查询设备列表
        List<ActualEquipmentPO> list = actualEquipmentMapper.findList(actualEquipmentDTO);
        // 将查询结果转换为PageInfo对象，用于展示分页信息
        PageInfo<ActualEquipmentPO> pageInfo = new PageInfo<>(list);
        // 返回PageInfo对象，包含设备列表和分页数据
        return pageInfo;
    }

    /**
     * 查询设备下拉框
     * @param actualEquipmentPO
     * @return
     */
    @Override
    public List<ActualEquipmentPO> all() {
        List<ActualEquipmentPO> all = actualEquipmentMapper.all();
        return all;
    }
}
